package com.kexilo.core.audit.domain;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.kexilo.core.common.core.domain.BaseEntity;

import java.time.LocalDateTime;

/**
 * 数据归档记录表 kx_sys_data_archive
 *
 * @author Kexilo
 */
@TableName("kx_sys_data_archive")
public class SysDataArchive extends BaseEntity {

    private static final long serialVersionUID = 1L;

    /** 归档ID */
    @TableId(type = IdType.AUTO)
    private Long archiveId;

    /** 归档任务名称 */
    private String taskName;

    /** 归档表名 */
    private String tableName;

    /** 归档条件 */
    private String archiveCondition;

    /** 归档开始时间 */
    private LocalDateTime startTime;

    /** 归档结束时间 */
    private LocalDateTime endTime;

    /** 归档数据量 */
    private Long archiveCount;

    /** 删除数据量 */
    private Long deleteCount;

    /** 归档状态（0:进行中 1:成功 2:失败） */
    private String status;

    /** 归档类型（1:定时归档 2:手动归档） */
    private String archiveType;

    /** 归档文件路径 */
    private String archiveFilePath;

    /** 错误信息 */
    private String errorMessage;

    /** 执行耗时（毫秒） */
    private Long duration;

    public SysDataArchive() {
    }

    public SysDataArchive(String taskName, String tableName) {
        this.taskName = taskName;
        this.tableName = tableName;
        this.status = "0";
        this.startTime = LocalDateTime.now();
    }

    // Getter and Setter methods
    public Long getArchiveId() {
        return archiveId;
    }

    public void setArchiveId(Long archiveId) {
        this.archiveId = archiveId;
    }

    public String getTaskName() {
        return taskName;
    }

    public void setTaskName(String taskName) {
        this.taskName = taskName;
    }

    public String getTableName() {
        return tableName;
    }

    public void setTableName(String tableName) {
        this.tableName = tableName;
    }

    public String getArchiveCondition() {
        return archiveCondition;
    }

    public void setArchiveCondition(String archiveCondition) {
        this.archiveCondition = archiveCondition;
    }

    public LocalDateTime getStartTime() {
        return startTime;
    }

    public void setStartTime(LocalDateTime startTime) {
        this.startTime = startTime;
    }

    public LocalDateTime getEndTime() {
        return endTime;
    }

    public void setEndTime(LocalDateTime endTime) {
        this.endTime = endTime;
    }

    public Long getArchiveCount() {
        return archiveCount;
    }

    public void setArchiveCount(Long archiveCount) {
        this.archiveCount = archiveCount;
    }

    public Long getDeleteCount() {
        return deleteCount;
    }

    public void setDeleteCount(Long deleteCount) {
        this.deleteCount = deleteCount;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public String getArchiveType() {
        return archiveType;
    }

    public void setArchiveType(String archiveType) {
        this.archiveType = archiveType;
    }

    public String getArchiveFilePath() {
        return archiveFilePath;
    }

    public void setArchiveFilePath(String archiveFilePath) {
        this.archiveFilePath = archiveFilePath;
    }

    public String getErrorMessage() {
        return errorMessage;
    }

    public void setErrorMessage(String errorMessage) {
        this.errorMessage = errorMessage;
    }

    public Long getDuration() {
        return duration;
    }

    public void setDuration(Long duration) {
        this.duration = duration;
    }

    /**
     * 判断归档是否成功
     */
    public boolean isSuccess() {
        return "1".equals(this.status);
    }

    /**
     * 判断归档是否失败
     */
    public boolean isFailed() {
        return "2".equals(this.status);
    }

    /**
     * 判断归档是否进行中
     */
    public boolean isRunning() {
        return "0".equals(this.status);
    }
}
